﻿function drawCircle(ctx) {
    var data = [90, 50, 50, 50, 50, 90];
    var colors = ['#ff0000', '0#fff000', '#f0f0f0', '#ff00ff', '#fff000', '#00ffff'];
    var sum = 0;
    for (var i = 0, len = data.length; i < len; i++) {
        sum += data[i];
    }

    var screen_w = 250;                                 //画布宽度        
    var point = { x: screen_w / 2, y: screen_w / 2 };   //圆心        
    var rudius = screen_w / 2;                          //半径        
    var start = -90;                                    //起始角度
    rudius -= 6

    //画5个同心圆
    for (var j = 0; j < 5; j++) {
        ctx.arc(point.x, point.y, rudius, rudius, 0, 360);
        rudius -= 25;
    }
    //画水平线
    ctx.moveTo(0, point.y);
    ctx.lineTo(screen_w, point.y);

    //画垂直线
    ctx.moveTo(point.x, 0);
    ctx.lineTo(point.x, screen_w);

    ctx.setLineWidth(3);
    ctx.setFillStyle('#1ee145');
    ctx.draw(); //绘制图形
}

var page = {
    timer: 0,
    timer2: 0,

    /* 此方法在第一次显示窗体前发生 */
    onLoad: function (event) {
        // var ctx = pm.createCanvasContext('Canvas1', this);
        // drawCircle(ctx);

        this.setData({
            Clock1: {
                //hour: { x: 10, y: 67 },
                //minute: { x: 8, y: 100 },
                second: { x: 0, y: 119 },
            },
            p1: { visible: false },
        })

        var that = this;
        var sec = 0;
        var count = 0;
        var scan = 0;
        var is_show = 1;
        var scan_count = 0;
        var find_count = 0;
        this.timer = setInterval(function () {
            that.setData({
                Clock1: { value: sec++ }
            })

            count++;
            scan++;
            if (1 < count && 1 == is_show) {
                is_show = 0;
                that.setData({ p1: {visible : true} });
                that.setData({ p2: {visible : true} });
                that.setData({ p3: {visible : true} });
            }
            if (8 < count) {
                that.setData({ p1: {visible : false} });
                that.setData({ p2: {visible : false} });
                that.setData({ p3: {visible : false} });
            }
            if(60 < count){
                is_show = 1;
                count = 0;
            }

            if(0 == scan % 60){
                scan_count++;
                find_count += 3;
                that.setData({scan_count:{value:scan_count.toString()}});
                that.setData({find_count:{value:find_count.toString()}});
            }
        }, 20);
    },


    /* 此方法展示窗体后发生 */
    onResume: function (event) {

    },

    /* 当前页状态变化为显示时触发 */
    onShow: function (event) {

    },

    /* 当前页状态变化为隐藏时触发 */
    onHide: function (event) {

    },

    /* 此方法关闭窗体前发生 */
    onExit: function (event) {
        clearInterval(this.timer);
    },

    onClick: function (event) {
        pm.navigateBack();
    },
};

Page(page);

page = 0;
